using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Pages : BasePage, ISiteSelected
{
    protected override void OnInit(EventArgs e)
    {
        this.PreRenderComplete += new EventHandler(Pages_PreRenderComplete);
        base.OnInit(e);
    }

    void Pages_PreRenderComplete(object sender, EventArgs e)
    {
        if (tvPages.Nodes.Count == 0)
        {
            tvPages.Visible = false;
            pnlNoPages.Visible = true;
        }
        else
        {
            tvPages.Visible = true;
            pnlNoPages.Visible = false;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        dsPages.GetData += new EventHandler<Acms.DataControls.PageHirechicalSelectEventArgs>(dsPages_GetData);
        if (!IsPostBack)
        {
            DataBind();
        }
    }

    public override void DataBind()
    {
        tvPages.DataBind();
    }

    void dsPages_GetData(object sender, Acms.DataControls.PageHirechicalSelectEventArgs e)
    {
        if (base.SiteId != null)
        {
            Acms.Bll.PageCollection root = Acms.Bll.PageCollection.GetRoot(base.SiteId.Value);
            e.SetData(root);
        }
    }
    protected void btnCreateRoot_Click(object sender, EventArgs e)
    {
        Server.Transfer("~/AddPage.aspx?isRoot=true");
    }
}
